<!--
 * @Descripttion: 详情弹框(查看、编辑、删除)
 * @version: v1.0.0
 * @Author: wang pingqi
 * @Date: 2021-04-19 15:47:59
 * @LastEditors: wang pingqi
 * @LastEditTime: 2021-05-10 11:16:27
-->
<template>
  <el-form
    ref="form2"
    :model="form"
    label-width="120px"
    label-position="right"
    class="form-wrapper"
    :disabled="status === 'r'"
  >
    <el-form-item label="房间内部" prop="_innerImages" verify>
      <Imgpond :count="9" v-model="form._innerImages" valueType="array" />
      <form-item-tip>建议图片尺寸：宽1000~2000，高1200 </form-item-tip>
    </el-form-item>
    <el-form-item label="陈列设施" prop="_facilityImages" verify>
      <Imgpond
        :count="9"
        v-model="form._facilityImages"
        valueType="array"
      />
      <form-item-tip>建议图片尺寸：宽1000~2000，高1200 </form-item-tip>
    </el-form-item>
    <el-form-item label="其他" prop="_otherImages" valueType="array">
      <Imgpond :count="9" v-model="form._otherImages" />
    </el-form-item>
  </el-form>
</template>

<script>
import { mapGetters } from "vuex";

export default {
  props: {
    form: {
      type: Object,
      required: true,
      default() {
        return {};
      },
    },
    status: {
      type: String,
      required: true,
    },
  },
  watch: {
    "form._innerImages": {
      handler(nv, ov) {
        if (nv) {
          this.formatImages(nv, "innerImages");
        }
      },
      immediate: true,
      deep: true,
    },
    "form._facilityImages": {
      handler(nv, ov) {
        if (nv) {
          this.formatImages(nv, "facilityImages");
        }
      },
      immediate: true,
      deep: true,
    },
    "form._otherImages": {
      handler(nv, ov) {
        if (nv) {
          this.formatImages(nv, "otherImages");
        }
      },
      immediate: true,
      deep: true,
    },
  },
  computed: {
    ...mapGetters(["dict"]),
  },
  data() {
    return {};
  },
  methods: {
    formatImages(target, name) {
      let temp = [];
      if (target && target.constructor === Array && target.length > 0) {
        target.forEach((its) => {
          temp.push({
            imageUrl: its,
          });
        });
      }
      if (target && target.constructor === String) {
        temp.push({
          imageUrl: target,
        });
      }
      this.$set(this.form, name, temp);
    },
  },
};
</script>

<style lang="scss" scoped>
</style>